package com.sxz.sbs.module.client.presenter;

import com.sxz.sbs.app.App;
import com.sxz.sbs.module.client.bean.ClientDetailsBean;
import com.sxz.sbs.module.client.bean.ClientDetailsPlanBean;
import com.sxz.sbs.module.client.view.ClientDetailsView;
import com.sxz.sbs.rx.RxPresenter;
import com.sxz.sbs.rx.RxSubscriber;
import com.sxz.sbs.rx.RxUtil;

import java.util.HashMap;

/**
 * 获取客户的简洁版的基本信息
 * （针对客户的基本信息页面的上半部分的信息获取）
 * @author hp
 */
public class ClientDetailsPresenter extends RxPresenter<ClientDetailsView>{
    /**
     * 获取客户简洁版信息
     * @param map
     */
    public void getClientDetails (final HashMap<String,Object> map) {
        addSubscribe(App.getInstance().getApi().getClientDetails(map)
                .compose(RxUtil.<ClientDetailsBean>handleResult())
                .subscribeWith(new RxSubscriber<ClientDetailsBean>(mView,true){
                    @Override
                    public void onNext(ClientDetailsBean data) {
                       mView.onClientDetailsSuccess(data);
                    }
                })
        );
    }

    /**
     * 获取客户跟进进度
     * @param map
     */
    public void getClientDetailsPlan (final HashMap<String,Object> map) {
        addSubscribe(App.getInstance().getApi().getClientDetailsPlan(map)
                .compose(RxUtil.<ClientDetailsPlanBean>handleResult())
                .subscribeWith(new RxSubscriber<ClientDetailsPlanBean>(mView){
                    @Override
                    public void onNext(ClientDetailsPlanBean data) {
                        mView.onClientDetailsPlanSuccess(data);
                    }
                })
        );
    }
    /**
     * 预约看车位
     * @param map
     */
    public void getLookStall (final HashMap<String,Object> map) {
        addSubscribe(App.getInstance().getApi().getLookStall(map)
                .compose(RxUtil.<String>handleResult())
                .subscribeWith(new RxSubscriber<String>(mView,true){
                    @Override
                    public void onNext(String data) {
                        mView.onLookStallSuccess(data);
                    }
                })
        );
    }
    /**
     * 添加意向客户
     * @param map
     */
    public void getAddIntentionClient (final HashMap<String,Object> map) {
        addSubscribe(App.getInstance().getApi().getAddIntentionClient(map)
                .compose(RxUtil.<String>handleResult())
                .subscribeWith(new RxSubscriber<String>(mView){
                    @Override
                    public void onNext(String data) {
                        mView.onAddIntentionClientSuccess(data);
                    }
                })
        );
    }
    /**
     * 新增通话记录
     * @param map
     */
    public void addCallRecord (final HashMap<String,Object> map) {
        addSubscribe(App.getInstance().getApi().addCallRecord(map)
                .compose(RxUtil.<String>handleResult())
                .subscribeWith(new RxSubscriber<String>(mView){
                    @Override
                    public void onNext(String data) {
                        mView.onAddCallRecordSuccess();
                    }
                })
        );
    }

}
